# -*- coding:utf-8 -*-

from fastapi import FastAPI
from fastapi.openapi.utils import get_openapi
from app.config import settings



def openapi_docs(app: FastAPI):
    # app.openapi_url=settings.SWAGGER_UI_OPENAPI_URL,
    # app.docs_url=settings.SWAGGER_UI_DOCS_URL,
    # app.redoc_url=settings.SWAGGER_UI_REDOC_RL,


    # custom_openapi
    def custom_openapi():
        if app.openapi_schema:
            return app.openapi_schema
        openapi_schema = get_openapi(
            description=settings.DESCRIPTION,
            version=settings.VERSION,
            title=settings.PROJECT_NAME,
            routes=app.routes,
        )
        app.openapi_schema = openapi_schema
        return app.openapi_schema

    app.openapi = custom_openapi

    return app